package com.example.canvastest;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.view.View;

/**
 * Created by 700 on 2018/7/31.
 */

public class DrawArc extends View{

    private Paint mpaint;
    private RectF rectFstrokeuctrue = new RectF(10,10,210,110);
    private RectF rectFstrokeucfalse = new RectF(10,160,210,260);
    private RectF rectFfilluctrue = new RectF(10,310,210,410);
    private RectF rectFfillucfalse = new RectF(10,460,210,560);

    public DrawArc(Context context, AttributeSet attrs,
                        int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    public DrawArc(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public DrawArc(Context context) {
        super(context);
    }

    private void initView(){
        mpaint = new Paint();
        mpaint.setColor(Color.BLUE);
        mpaint.setStyle(Paint.Style.STROKE);
        mpaint.setStrokeWidth(6);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        initView();
        canvas.drawArc(rectFstrokeuctrue,0,120,true,mpaint);
        canvas.drawArc(rectFstrokeucfalse,0,120,false,mpaint);
        mpaint.setStyle(Paint.Style.FILL);
        canvas.drawArc(rectFfilluctrue,0,120,true,mpaint);
        canvas.drawArc(rectFfillucfalse,0,120,false,mpaint);
    }
}
